package cn.edu.scnu.thewonderofink.ui.home

import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import cn.edu.scnu.thewonderofink.R

class BannerAdapter(private val list: List<Int>) :
    RecyclerView.Adapter<BannerAdapter.ViewHolder>() {
    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val imageItem : ImageView = view.findViewById(R.id.banner_image)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).
        inflate(R.layout.banner_item, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val image = list[position]
        holder.imageItem.setImageResource(image)
    }

    override fun getItemCount() = list.size

}
